<?php

/**
 * Description of JavaScriptView
 *
 * @author Ian Clarence <ian.clarence@gmail.com>
 */
final class JavaScriptView extends ViewJavaScript {
    
    /**
     * The constructor.
     */
    public function __construct($fields = array()) {
        parent::__construct($fields);
        $this->applyCodeSnippets();
    }
    
    private function applyCodeSnippets() {
        
        /**
         * Detecting which browser is used. 
         */
        $this->addCodeSnippets(BrowserDetectJs::make($this->fields));
        
        switch (DEBUGGING_MODE) {
            case OFF:
                break;
            case ON:
                
                /**
                * Turns the background yellow when hovering over a link.
                */
                $this->addCodeSnippets(TestJs::make($this->fields));
                
                break;
        }
    }

    /**
     * Viewing the script: returning the JavaScript.
     *
     * @return string
     */
    public function view() {
        return parent::view();
    }

}